package com.wo.cloud.log.config;

import com.wo.cloud.kafka.channel.LogChannel;
import com.wo.cloud.log.aspect.LogAspect;
import com.wo.cloud.log.event.LogListener;
import com.wo.cloud.log.feign.ICommonLogProvider;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2021/4/30 15:06
 * Description: 日志配置中心
 */

@EnableAsync
@Configuration
@RequiredArgsConstructor
@ConditionalOnWebApplication
//@EnableConfigurationProperties(value = LogProperties.class)
@EnableBinding(LogChannel.class)
public class LogConfiguration {

    //    private ISysLogFeign sysLogFeign;

//    private final ICommonLogProvider commonLogProvider;

    private final LogChannel logChannel;


    @Bean
    public LogListener sysLogListener() {
        return new LogListener(logChannel);
    }

    @Bean
    public LogAspect logAspect(ApplicationContext applicationContext) {
        return new LogAspect(applicationContext);
    }
}

